import { userStatusUrl } from '../../../../api/individual'
import { post } from '../../../../utils/index'

Page({
  data: {
    userStatus: {}
  },
  async loadData () { // 获取员工审核状态entryStatus 
    let { data, data: { entryStatus, entryProcess } } = await post(userStatusUrl)
    if (entryProcess === 4 && entryStatus === 1) {
      data.img = `../../../../assets/img/checkSuccess_img.png`
      data.subTitle = '派遣审核通过了，请前往签署合同'
    } else {
      // 特殊处理，当派遣审核被拒绝，小程序依旧显示审核中，后端后台才是显示拒绝
      if (entryProcess === 4 && entryStatus === 2) {
        entryStatus = 0
        data.entryStatus = 0
      }
      data.img = `../../../../assets/img/${entryStatus === 2 ? 'checkFail' : 'checking'}_img.png`
      data.title = entryStatus === 2 ? '办理失败' : '等待处理'
      data.subTitle = entryStatus === 2 ? data.entryMsg : '已提交审核，等待工作人员处理'
    }
    this.setData({ userStatus: data })
  },
  back () { // 返回编辑
    wx.navigateTo({ url: '/pages/individual/entry/entry/entry?page=entry' })
  },
  sign () { // 签署合同
    wx.navigateTo({ url: '/pages/webview/webview?url=/dispatch-sign/#/sign' })
  },
  onShow () {
    this.loadData()
  },
  onPullDownRefresh () {
    this.loadData()
  }
})